#include "gcpch.h"
#include "gui_fontstyle.h"

bool geek_gui_fontstyle_resolve(const geek_gui_fontstyle *src, geek_gui_fontstyle *dst)
{
    memset(dst,0,sizeof(geek_gui_fontstyle));

    for(const geek_gui_fontstyle *cur = src; cur != NULL; cur = cur->parent)
    {
        if((cur->mask & geek_gui_fsmask_face) && !(dst->mask & geek_gui_fsmask_face))
        {
            wcscpy_s(dst->face,cur->face);
        }

        if((cur->mask & geek_gui_fsmask_height) && !(dst->mask & geek_gui_fsmask_height))
        {
            dst->height = cur->height;
        }

        dst->mask |= cur->mask;
    }

    return (dst->mask & geek_gui_fsmask_allbits) == geek_gui_fsmask_allbits;
}

void geek_gui_fontstyle_make_logfont(const geek_gui_fontstyle *style, LOGFONT *lf)
{
    memset(lf,0,sizeof(LOGFONT));

    lf->lfHeight = style->height;
    wcscpy_s(lf->lfFaceName,style->face);

    lf->lfCharSet = DEFAULT_CHARSET;
    lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
    lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
    lf->lfQuality = DEFAULT_QUALITY;
    lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
}
